package com.pubinfo.passbook.common.service.master.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pubinfo.passbook.common.entity.TFileElectronicFtp;
import com.pubinfo.passbook.common.entity.TSourceArtificial;
import com.pubinfo.passbook.common.mapper.TSourceArtificialMapper;
import com.pubinfo.passbook.common.model.dto.MDM.TSourceArtificialParam;
import com.pubinfo.passbook.common.model.vo.rule.TSourceArtificialDetailVo;
import com.pubinfo.passbook.common.service.master.ITSourceArtificialService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xuhong
 * @since 2021-11-23
 */
@Service
public class TSourceArtificialServiceImpl extends ServiceImpl<TSourceArtificialMapper, TSourceArtificial> implements ITSourceArtificialService {

  @Override
  public IPage<TSourceArtificialDetailVo> listArtificial(TSourceArtificialParam param) {
    IPage<TSourceArtificialDetailVo> iPage = page(param.getPage("create_time"));
    return this.baseMapper.listArtificial(iPage, param);
  }

  
  @Override
  public IPage<TSourceArtificialDetailVo> selectArtificialByCreateUser(TSourceArtificialParam param) {
    return listArtificial(param);
  }
  

  @Override
  public List<TFileElectronicFtp> findFileFtpByArtificialList(List<TSourceArtificial> artificialList) {
    if (CollectionUtils.isEmpty(artificialList)) {
      return null;
    }
    List<String> ids = artificialList.stream().map(TSourceArtificial::getId).collect(Collectors.toList());
    return this.baseMapper.findFileFtpByArtificiaIds(ids);
  }
}
